// 对帖子进行处理并返回
function YyTY_Topic_Item(Objects) {
    var n = Objects.viewCount > 99 ? '99 +' : Objects.viewCount;
    return `
         <a href="/web/HaiJiaoH5/topic_detail/?id=${Objects.topicId}" class="topic_item Yy-d-flex">
        <div class="topic_img"><img src="/static/CloudImages/loading_gif/Yin and Yang.gif" alt="Yy"
                class="Yy-h-100 Yy-w-100 Yy-br-8" data-yy_path="0"></div>
        <div class="topic_info ">
            <h3 class="Yy-text-ellipsis2 layui-font-16">${Objects.title}</h3>
            <div class="topic_user_info Yy-d-flex Yy-ju-sb Yy-mt-10px">
                <span class="user_name layui-elip Yy-text-cen"><span class="iconfont icon-wode"> </span>
                    ${Objects.user.nickname}</span>
                <span class="topic_view layui-elip Yy-text-cen"><span class="iconfont icon-yanjing-"> </span> ${n}</span>
                <span class="notactive"> ${Objects.node.name}</span>
            </div>
        </div>
    </a> 
    `;
}

// 返回帖子列表
function YyTY_Return_Topic_List(data_list) {
    var list = [];

    for (let i = 0; i < data_list.length; i++) {
        list.push(YyTY_Topic_Item(data_list[i]))
    }
    return list;
}

// 对图片进行处理
function YyTY_Show_Img(data_list) {
    /**
     * data_list: 帖子列表
     */
    setTimeout(() => {
        var imgs = document.querySelectorAll('.topic_box .topic_item [data-yy_path="0"]');
    let bb_a = (new YyHaiJiao);
    for (let i = 0; i < imgs.length; i++) {
        if (data_list[i] == undefined || data_list[i].attachments == null) {
            continue;
        } else {
            setTimeout(() => {
                axios.get(data_list[i].attachments[0].remoteUrl).then(res => {
                    var o = bb_a.decode(res.data);
                    imgs[i].src = o;
                    imgs[i].setAttribute('data-yy_path', '1');
                })
            }, 1000);
        }

    }
    }, 800);
}
